#ifndef SPINLOCK_HPP_
#define SPINLOCK_HPP_

#define SPINLOCK_SIGNATURE ('SPIN')

#include <Mint/Types.h>
#include <Mint/Errors.h>

class CThread;

class CSpinlock
{
public:
	CSpinlock();
	~CSpinlock();

	void Lock( void );
	void Unlock( void );
	bool IsLocked( void );

	CThread * GetThread( void ) { return fThread; }

private:
	enum
	{
		Ready,
		Locked,
		Disposed,
	};

#if PARANOID
	uint32 fSignature;
#endif

	CThread * fThread;
	vint32 fState;
};

#endif /*SPINLOCK_HPP_*/
